<link href="<?php echo base_url('/assets/js/jquery-easyui-1.3.3/themes/default/easyui.css') ?>" rel="stylesheet" />
<script src="<?php echo base_url('/assets/js/jquery-easyui-1.3.3/jquery.easyui.min.js') ?>"></script>

<style>
input.input-mini { width:50px; }
div.form div.fields div.field div.input select { padding:6px; }
fieldset { border:1px dotted #999999; padding:10px; margin:10px 0; }
fieldset legend { font-weight:bold; }
fieldset .label { margin-left:10px !important; }
div.form div.fields div.field { border-bottom:none; }
div.form div.fields fieldset div.field div.input { margin:0 0 0 189px; }
#content div.box div.form div.fields div.field div.label { padding:8px 0 0; }

#footer { z-index:1; }
.tabs li { padding:0px !important; }
.panel { border:none; padding:0px; }
</style>

<div class="box">

	<div class="title">
		<?php if (get_instance()->uri->segment(2) == 'add') { ?>
			<h5><?php echo sprintf(lang('text_heading_title_input_site'), 'Add') ?></h5>
		<?php } else { ?>
			<h5><?php echo sprintf(lang('text_heading_title_input_site'), 'Edit') ?></h5>
		<?php } ?>
	</div>

	<!-- start:siteInfo -->
	<div id="siteInfo" class="easyui-tabs" style="width:auto; height:auto;">
		<!-- start:contentGeneralInfo -->
		<div id="contentGeneralInfo" title="General Info">
			<?php echo form_open('', 'id="formGeneralInfo" class="form-horizontal"') ?>
				
			<?php echo $cmd_input_general_info ?>
			<?php echo @form_hidden('siteId', set_value('siteId', $general_info['site_id'])) ?>
			
			<div class="form">
				<div class="fields">
					
					<div class="field">
						<div class="label"><label for="siteIdText">Site ID:</label></div>
						<?php if (get_instance()->uri->segment(2) == 'edit') { ?>
						<div class="label" style="position:relative; left:194px;"><label><?php echo $general_info['site_id_text'] ?></label></div>
						<?php } else { ?>
						<div class="input">
							<?php echo @form_input('siteIdText', set_value('siteIdText', $general_info['site_id_text']), 'id="siteIdText" class="medium uppercase"') ?>
						</div>
						<?php } ?>
					</div>
					
					<div class="field">
						<div class="label">
							<label for="oldSiteId">Reference Site ID:</label>
						</div>
						<div class="input">
							<?php echo @form_input('oldSiteId', set_value('oldSiteId', $general_info['old_site_id']), 'id="oldSiteId" class="medium uppercase"') ?>
						</div>
					  
					</div>
					
					<div class="field">
						<div class="label">
							<label for="siteName">Site Name:</label>
						</div>
						<div class="input">
							<?php echo @form_input('siteName', set_value('siteName', trim($general_info['site_name'])), 'id="siteName" class="medium"') ?>
						</div>
					</div>
				  
					<div class="field">
						<div class="label">
							<label for="siteType">Site Type:</label>
						</div>
						<div class="input">
							<?php echo @form_dropdown('siteType', $site_type, set_value('siteType', $general_info['site_type']), 'id="siteType" class=""') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label">
							<label for="siteProfile">Site Profile:</label>
						</div>
						<div class="input">
							<?php echo @form_dropdown('siteProfile', $site_profile, set_value('siteProfile', $general_info['site_profile']), 'id="siteProfile" class=""') ?>
						</div>
					</div>
				  
					<div class="field">
						<div class="label">
							<label for="siteLocationLat">Nominal Latitude:</label>
						</div>
						<div class="input">
							<?php echo @form_input('siteLocationLat', set_value('siteLocationLat', $general_info['latitude']), 'id="siteLocationLat" class="medium latlng-number"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label">
							<label for="siteLocationLng">Nominal Longitude:</label>
						</div>
						<div class="input">
							<?php echo @form_input('siteLocationLng', set_value('siteLocationLng', $general_info['longitude']), 'id="siteLocationLng" class="medium latlng-number"') ?>
						</div>
					</div>
				  
					<div class="field">
						<div class="label">
							<label for="siteAddress">Site Address:</label>
						</div>
						<div class="input">
							<?php echo @form_input('siteAddress', set_value('siteAddress', $general_info['site_address']), 'id="siteAddress" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">						   
						<div class="label">
							<label for="propinsi">Province:</label>
						</div>
						<div class="input">
							<?php echo @form_dropdown('propinsi', $propinsi, set_value('propinsi', $general_info['propinsi']), 'id="propinsi"') ?>
						</div>								
					</div>
					
					<div class="field">						   
						<div class="label">
							<label for="kabupaten">Kabupaten:</label>
						</div>
						<div class="input">
							<?php echo @form_dropdown('kabupaten', $kabupaten, set_value('kabupaten', $general_info['kabupaten']), 'id="kabupaten"') ?>						    
						</div>
					</div>
				  
					<div class="field">						   
						<div class="label">
							<label for="kecamatan">Kecamatan:</label>
						</div>
						<div class="input">
							<?php echo @form_dropdown('kecamatan', $kecamatan, set_value('kecamatan', $general_info['kecamatan']), 'id="kecamatan"') ?>
						</div>
					</div>
					
					<div class="field">						   
						<div class="label">
							<label for="kelurahan">Kelurahan:</label>
						</div>
						<div class="input">
							<?php echo @form_input('kelurahan', set_value('kelurahan', $general_info['kelurahan']), 'id="kelurahan" class="medium"') ?>							
						</div>
					</div>
				  
					<div class="field">
						<div class="label">
							<label for="kodePos">Kode Pos:</label>
						</div>
						<div class="input">
							<?php echo @form_input('kodePos', set_value('kodePos', $general_info['kode_pos']), 'id="kodePos" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label">
							<label for="name">Site Specification:</label>
						</div>
						<div class="input">
							<?php echo @form_dropdown('siteSpecification', $site_specification, set_value('siteSpecification', $general_info['site_specification']), 'id="siteSpecification"') ?>
						</div>
					</div>
				  
					<div class="control-group" style="display:none">
						<label class="control-label" for="name">
							Cost Center:
						</label>
						<div class="controls controls-row">
							<?php echo @form_input('costCenter', set_value('costCenter', $general_info['cost_center']), 'class="span6" placeholder="Cost Center" readonly="readonly"') ?>
						</div>
					</div>
				  
				  <div class="control-group" style="display:none">
					<label class="control-label" for="name">
					  Branch:
					</label>
					<div class="controls controls-row">
						<?php echo @form_input('branch', set_value('branch', $general_info['branch']), 'class="span6" placeholder="Surabaya" readonly="readonly"') ?>
					</div>
				  </div>
				  <div class="control-group" style="display:none">
					<label class="control-label" for="name">
					  Sub Branch
					</label>
					<div class="controls controls-row">
						<?php echo @form_input('subBranch', set_value('subBranch', $general_info['sub_branch']), 'class="span6" placeholder="Surabaya" readonly="readonly"') ?>
					</div>
				  </div>
				  
					<div class="field">
						<div class="label">
							<label for="cluster">Cluster:</label>
						</div>
						<div class="input">
							<?php echo @form_input('cluster', set_value('cluster', $general_info['cluster']), 'id="cluster" class="medium"') ?>
						</div>
					</div>
				  
					<div class="field">
						<div class="label">
							<label for="guardHouse">Guard House:</label>
						</div>
						<div class="input">
							<?php echo @form_checkbox('guardHouse', 1, set_value('guardHouse', $general_info['guard_house']), 'id="guardHouse"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label">
							<label for="24HourAccess">24 Hour Access:</label>
						</div>
						<div class="input">
							<label>
								<?php echo @form_checkbox('24HourAccess', 1, set_value('24HourAccess', $general_info['24_hour_access']), 'id="24HourAccess"') ?>
							</label>
						</div>
					</div>
					
					<div class="field">
						<div class="label">
							<label for="cmeInsured">CME Insured:</label>
						</div>
						<div class="input">
							<label>
								<?php echo @form_checkbox('cmeInsured', 1, set_value('cmeInsured', $general_info['cme_insured']), 'id="cmeInsured"') ?>
							</label>
						</div>
					</div>
					
					<div class="field">
						<div class="label">
							<label for="equipmentInsured">Equipment Insured:</label>
						</div>
						<div class="input">
							<label>
								<?php echo @form_checkbox('equipmentInsured', 1, set_value('equipmentInsured', $general_info['equipment_insured']), 'id="equipmentInsured"') ?>
							</label>
						</div>
					</div>
					
					<div class="field">
						<div class="label">
							<label for="polisNumber">Polis Number:</label>
						</div>
						<div class="input">
							<?php echo @form_input('polisNumber', set_value('polisNumber', $general_info['polis_number']), 'class="medium"') ?>
						</div>
					</div>
				  
					<div class="field">
						<div class="label">
							<label for="cmePartnerName">CME Partner:</label>
						</div>
						<div class="input">                            
							<?php
							$cmePartner = @get_instance()->core->view_row('t_mtr_cme_partner', array('cme_partner_id' => (int) $general_info['cme_partner']));
							
							echo @form_input('cmePartnerName', set_value('cmePartnerName', trim($cmePartner['nama'])), 'id="cmePartnerName" class="medium" placeholder="Auto complete..."');
							echo @form_hidden('cmePartner', set_value('cmePartner', $general_info['cme_partner']));
							?>
							<span class="add-on">
								<span class="fs1" aria-hidden="true" data-icon="&#xe086;"></span>
							</span>
						</div>
					</div>
					
					<div class="field">
						<div class="label">
							<label for="picSmart">PIC Smart:</label>
						</div>
						<div class="input">
							<?php echo @form_input('picSmart', set_value('picSmart', trim($general_info['pic_smart'])), 'id="picSmart" class="medium"') ?>
							</div>
					</div>
					
					<div class="field">
						<div class="label">
							<label for="phonePicSmart">Phone PIC Smart:</label>
						</div>
						<div class="input">
							<?php echo @form_input('phonePicSmart', set_value('phonePicSmart', $general_info['phone1']), 'id="phonePicSmart" class=""') ?>
						</div>
					</div>
				 
					<div class="field">
						<div class="label">
							<label for="picCmePartner">PIC CME Partner:</label>
						</div>
						<div class="input">
							<?php echo @form_input('picCmePartner', set_value('picCmePartner', trim($general_info['pic_cme_partner'])), 'id="picCmePartner" class="medium"') ?>
							</div>
					</div>
					
					<div class="field">
						<div class="label">
							<label for="picCmePartner">Phone PIC CME Partner:</label>
						</div>
						<div class="input">
							<?php echo @form_input('phonePicCmePartner', set_value('phonePicCmePartner', $general_info['phone2']), 'id="phonePicCmePartner" class=""') ?>
						</div>
					</div>
				  
					<div class="field">
						<div class="label">
							<label for="cutOverDate">Cut Over Date:</label>
						</div>
						<div class="input">
							<?php echo @form_input('cutOverDate', set_value('cutOverDate', $general_info['cut_over_date']), 'id="cutOverDate" class="date" placeholder="YYYY-MM-DD" readonly="readonly"') ?>
						</div>
						<div class="label" style="left:478px"><a href="javascript:void(0)" onclick="clearField('cutOverDate')">clear</a></div>
					</div>
					
					<div class="field">
						<div class="label">
							<label for="verifiedOnAir">Verified On Air (PAT):</label>
						</div>
						<div class="input">
							<?php echo @form_input('verifiedOnAir', set_value('verifiedOnAir', $general_info['verified_on_air']), 'id="verifiedOnAir" class="medium"') ?>
						</div>
					</div>
					
					<div class="buttons">
						<input type="submit" value="Submit" />
					</div>
				  
				</div>
			</div>
			
			<?php echo form_close() ?>
		</div>
		<!-- end:contentGeneralInfo -->
		
		<!-- start:contentSiteKeepers -->
		<div id="contentSiteKeepers" title="Site Keepers">
			
			<!-- form:Site Keepers -->				
			<?php echo form_open('', 'id="formSiteKeepers" class="form-horizontal"') ?>
			
			<?php echo $cmd_input_site_keepers ?>
			<?php echo @form_hidden('siteId', set_value('siteId', $general_info['site_id'])) ?>
			
			<div class="form">
				<div class="fields">
					
					<div class="field">
						<div class="label"><label for="name">Name:</label></div>
						<div class="input">
							<?php echo @form_input('name', set_value('name', trim($site_keepers['name'])), 'id="name" class="medium"') ?>
						</div>
					</div>
					  
					<div class="field">
						<div class="label"><label for="address">Address:</label></div>
						<div class="input">
							<?php echo @form_input('address', set_value('address', trim($site_keepers['address'])), 'id="address" class="medium"') ?>
						</div>
					</div>
					 
					<div class="field">
						<div class="label"><label for="phone">Phone:</label></div>
						<div class="input">
							<?php echo @form_input('phone', set_value('phone', trim($site_keepers['phone'])), 'id="phone" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="salary">Salary / Month:</label></div>
						<div class="input">
							<?php echo @form_input('salary', set_value('salary', $site_keepers['salary_month']), 'id="salary" class="medium currency"') ?>
						</div>
					</div>
					  
					<div class="field">
						<div class="label"><label for="hiredBySmart">Hired By Smart:</label></div>
						<div class="input">
							<?php echo @form_checkbox('hiredBySmart', 1, set_value('hiredBySmart', $site_keepers['hired_by_smart']), 'id="hiredBySmart"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="remark">Remark:</label></div>
						<div class="input">                      
							<?php echo @form_textarea('remark', set_value('remark', trim($site_keepers['remark'])), 'id="remark" style="width:550px; height:100px;"') ?>
						</div>
					</div>
					
					<div class="buttons">
						<input type="submit" value="Submit" />
					</div>
				</div>
			</div>
			<?php echo form_close() ?>
			
			<!-- / form:Site Keepers -->
		</div>
		<!-- end:contentSiteKeepers -->
		
		<!-- start:contentPLN -->
		<div id="contentPLN" title="Power (PLN)">
				
			<!-- form:PLN -->			
			<?php echo form_open('', 'id="formPLN" class="form-horizontal"') ?>
			
			<?php echo $cmd_input_pln ?>
			<?php echo @form_hidden('siteId', set_value('siteId', $general_info['site_id'])) ?>
			
			<div class="form">
				<div class="fields">
					
					<div class="field">
						<div class="label"><label for="handoverProject">Handover Project:</label></div>
						<div class="input">
							<?php echo @form_input('handoverProject', set_value('handoverProject', $pln['handover_project']), 'id="handoverProject" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="handoverRemark">Handover Remark:</label></div>
						<div class="input">
							<?php echo @form_input('handoverRemark', set_value('handoverRemark', $pln['handover_remark']), 'id="handoverRemark" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="idPelangganPLN">Customer ID:</label></div>
						<div class="input">
							<?php echo @form_input('idPelangganPLN', set_value('idPelangganPLN', $pln['id_pelanggan_pln']), 'id="idPelangganPLN" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="atasNamaPelanggan">Customer Name:</label></div>
						<div class="input">
							<?php echo @form_input('atasNamaPelanggan', set_value('atasNamaPelanggan', trim($pln['atas_nama_pelanggan'])), 'id="atasNamaPelanggan" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="plnConnectedDate">PLN Connected Date:</label></div>
						<div class="input">
							<?php echo @form_input('plnConnectedDate', set_value('plnConnectedDate', $pln['pln_connected_date']), 'id="plnConnectedDate" class="date" readonly="readonly"') ?>
						</div>
						<div class="label" style="left:478px"><a href="javascript:void(0)" onclick="clearField('plnConnectedDate')">clear</a></div>
					</div>
					  
					<div class="field">
						<div class="label"><label for="namaUPJPLN">Name of UPJ PLN:</label></div>
						<div class="input">
							<?php echo @form_input('namaUPJPLN', set_value('namaUPJPLN', trim($pln['nama_upj_pln'])), 'id="namaUPJPLN" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="woDismantleDate">WO Dismantle Date:</label></div>
						<div class="input">
							<?php echo @form_input('woDismantleDate', set_value('woDismantleDate', $pln['wo_dismantle_date']), 'id="woDismantleDate" class="date" readonly="readonly"') ?>
						</div>
						<div class="label" style="left:478px"><a href="javascript:void(0)" onclick="clearField('woDismantleDate')">clear</a></div>
					</div>
					
					<div class="field">
						<div class="label"><label for="plnDisconnectDate">PLN Disconnect Date:</label></div>
						<div class="input">
							<?php echo @form_input('plnDisconnectDate', set_value('plnDisconnectDate', $pln['wo_dismantle_date']), 'id="plnDisconnectDate" class="date" readonly="readonly"') ?>
						</div>
						<div class="label" style="left:478px"><a href="javascript:void(0)" onclick="clearField('plnDisconnectDate')">clear</a></div>
					</div>
					
					<div class="field">
						<div class="label"><label for="trafoBlast">Trafo Blast:</label></div>
						<div class="input">
							<?php
							$dataTrafoBlast = get_instance()->core->view_all('t_mtr_trafo', NULL, 'nama');
							$trafoBlast = array('' => '- Choose one -');
							foreach ($dataTrafoBlast as $trafo) {
								$trafoBlast[$trafo['trafo_id']] = $trafo['nama'];
							}
							echo @form_dropdown('trafoBlast', $trafoBlast, set_value('trafoBlast', $pln['trafo_blast']), 'id="trafoBlast"');
							?>
						</div>
					</div>
					  
					<div class="field">
						<div class="label"><label for="trafoCapacity">Trafo Capacity:</label></div>
						<div class="input">
							<?php
							$dataTrafoCapacity = get_instance()->core->view_all('t_mtr_trafo_capacity', NULL, 'nama');
							$trafoCapacity = array('' => '- Choose one -');
							foreach ($dataTrafoCapacity as $trafo) {
								$trafoCapacity[$trafo['trafo_capacity_id']] = $trafo['nama'];
							}
							echo @form_dropdown('trafoCapacity', $trafoCapacity, set_value('trafoCapacity', $pln['trafo_capacity']), 'id="trafoCapacity"');
							?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="trafoMaintainedBySmartfren">Trafo Maintained by Smartfren:</label></div>
						<div class="input">
							<?php
							$trafoMaintainedBySmartfren = array('' => '- Choose one -', 1 => 'Yes', 0 => 'No');
							echo @form_dropdown('trafoMaintainedBySmartfren', $trafoMaintainedBySmartfren, set_value('trafoMaintainedBySmartfren', $pln['trafo_maintained_by_smartfren']), 'id="trafoMaintainedBySmartfren" class="span3"');
							?>
						</div>
					</div>
					  
					<div class="field">
						<div class="label"><label for="kwhType">KWH Type:</label></div>
						<div class="input">                           
							<?php
							$dataKwhType = get_instance()->core->view_all('t_mtr_kwh_type', NULL, 'descr');
							$kwhType = array('' => '- Choose one -');
							foreach ($dataKwhType as $kwh) {
								$kwhType[$kwh['kwh_type_id']] = $kwh['descr'];
							}
							echo @form_dropdown('kwhType', $kwhType, set_value('kwhType', $pln['kwh_type']), 'id="kwhType"');
							?>
						</div>		
					</div>
					
					<div class="field">
						<div class="label"><label for="plnPhase">PLN Phase:</label></div>
						<div class="input">
							<?php echo @form_input('plnPhase', set_value('plnPhase', $pln['pln_phase']), 'id="plnPhase" class="medium number"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="plnCapacity">PLN Capacity (KVA):</label></div>
						<div class="input">
							<?php echo @form_input('plnCapacity', set_value('plnCapacity', $pln['pln_capacity']), 'id="plnCapacity" class="medium number"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="tarifType">Tarif Type:</label></div>
						<div class="input">
							<?php
							$tarifType = array(1 => 'Reguler', 2 => 'Non-Reguler');
							echo @form_dropdown('tarifType', $tarifType, set_value('tarifType', $pln['tarif_type']), 'id="tarifType"');
							?>
						</div>
					</div>
					
					<div class="field">
					   <div class="label"><label for="tarifName">Tarif Name:</label></div>
						<div class="input">
							<?php
							$dataTarifName = get_instance()->core->view_all('t_mtr_tarif_name', NULL, 'nama');
							$tarifName = array('' => '- Choose one -');
							foreach ($dataTarifName as $tarif) {
								$tarifName[$tarif['tarif_name_id']] = $tarif['nama'];
							}
							echo @form_dropdown('tarifName', $tarifName, set_value('tarifName', $pln['tarif_name']), 'id="tarifName"');
							?>
						</div>
					</div>
						
					<div class="field">
						<div class="label"><label for="caraPembayaran">Payment Method:</label></div>
						<div class="input">
							<?php
							$dataCaraPembayaran = get_instance()->core->view_all('t_mtr_cara_pembayaran', NULL, 'descr');
							$caraPembayaran = array('' => '- Choose one -');
							foreach ($dataCaraPembayaran as $pembayaran) {
								$caraPembayaran[$pembayaran['cara_pembayaran_id']] = $pembayaran['descr'];
							}
							echo @form_dropdown('caraPembayaran', $caraPembayaran, set_value('caraPembayaran', $pln['cara_pembayaran']), 'id="caraPembayaran"');
							?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="remarks">Remarks:</label></div>
						<div class="input">
							<?php echo @form_textarea('remarks', set_value('remarks', trim($pln['remarks'])), 'id="remarks" style="width:550px; height:100px;"') ?>
						</div>
					</div>
					
					<fieldset>  
						<legend>Genset</legend>
						
						<div class="field">
							<div class="label"><label for="permanentGenset">Permanent Genset:</label></div>
							<div class="input">
								<?php
								$permanentGenset = array(1 => 'Yes', 0 => 'No');
								echo @form_dropdown('permanentGenset', $permanentGenset, set_value('permanentGenset', $pln['permanent_genset']), 'id="permanentGenset"');
								?>
							</div>
						</div>
							
						<div class="field">
							<div class="label"><label for="gensetBrand">Genset Brand:</label></div>
							<div class="input">
								<?php echo @form_input('gensetBrand', set_value('gensetBrand', trim($pln['genset_brand'])), 'id="gensetBrand" class="medium"') ?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="gensetCapacity">Genset Capacity (KVA):</label></div>
							<div class="input">
								<?php echo @form_input('gensetCapacity', set_value('gensetCapacity', $pln['genset_capacity']), 'id="gensetCapacity" class="number"') ?>
							</div>
						</div>
							
						<div class="field">
							<div class="label"><label for="gensetOwnership">Genset Ownership:</label></div>
							<div class="input">
								<?php
								$dataGensetOwnership = get_instance()->core->view_all('t_mtr_genset_ownership', NULL, 'nama');
								$gensetOwnership = array('' => '- Choose one -');
								foreach ($dataGensetOwnership as $owner) {
									$gensetOwnership[$owner['genset_ownership_id']] = $owner['nama'];
								}
								echo @form_dropdown('gensetOwnership', $gensetOwnership, set_value('gensetOwnership', $pln['genset_ownership']), 'id="gensetOwnership"');
								?>
							</div>
						</div>
					</fieldset>
					
					<div class="buttons">
						<input type="submit" value="Submit" />
					</div>
				</div>
			</div>
			<?php echo form_close() ?>			
			<!-- form:PLN -->
		</div>
		<!-- end:contentPLN -->
		
		<!-- start:contentTower -->
		<div id="contentTower" title="Tower">
			<?php echo form_open('', 'id="formTower"') ?>
			
			<?php echo $cmd_input_tower ?>
			<?php echo @form_hidden('siteId', set_value('siteId', $general_info['site_id'])) ?>
			
			<div class="form">
				<div class="fields">
					
					<div class="field">
						<div class="label"><label for="kepemilikanTower">Tower Ownership:</label></div>
						<div class="input">
							<?php
							$dataKepemilikanTower = get_instance()->core->view_all('t_mtr_tower_provider', NULL, 'vendor_id');
							$kepemilikanTower = array('' => '- Choose one -');
							foreach ($dataKepemilikanTower as $pemilikTower) {
								$kepemilikanTower[$pemilikTower['tower_provider_id']] = $pemilikTower['vendor_id'].'|'.$pemilikTower['nama_pemilik_tower'];
							}
							echo @form_dropdown('kepemilikanTower', $kepemilikanTower, set_value('kepemilikanTower', $tower['kepemilikan_tower']), 'id="kepemilikanTower"');
							?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="namaPemilikTower">Name of Tower Owner:</label></div>
						<div class="input">
							<?php echo @form_input('namaPemilikTower', set_value('namaPemilikTower', $tower['nama_pemilik_tower']), 'id="namaPemilikTower" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="telpPemilikTower">Phone of Tower Owner:</label></div>
						<div class="input">
							<?php echo @form_input('telpPemilikTower', set_value('telpPemilikTower', $tower['no_telp_pemilik_tower']), 'id="telpPemilikTower" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="towerType">Tower Type:</label></div>
						<div class="input">
							<?php
							$dataTowerType = get_instance()->core->view_all('t_mtr_tower_type', NULL, 'tower_type_name');
							$towerType = array('' => '- Choose one -');
							foreach ($dataTowerType as $type) {
								$towerType[$type['tower_type_id']] = $type['tower_type_name'];
							}
							echo @form_dropdown('towerType', $towerType, set_value('towerType', $tower['tower_type']), 'id="towerType"');
							?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="towerLegNo">Tower Leg No:</label></div>
						<div class="input">
							<?php
							$dataTowerLegNo = get_instance()->core->view_all('t_mtr_tower_leg_no', NULL, 'nama');
							$towerLegNo = array('' => '- Choose one -');
							foreach ($dataTowerLegNo as $no) {
								$towerLegNo[$no['tower_leg_no_id']] = $no['nama'];
							}
							echo @form_dropdown('towerLegNo', $towerLegNo, set_value('towerLegNo', $tower['tower_leg_no']), 'id="towerLegNo"');
							?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="towerHeight">Tower Height:</label></div>
						<div class="input">
							<?php echo @form_input('towerHeight', set_value('towerHeight', $tower['tower_height']), 'id="towerHeight" class="number"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="towerFabricator">Tower Fabricator:</label></div>
						<div class="input">
							<?php echo @form_input('towerFabricator', set_value('towerFabricator', trim($tower['tower_fabricator'])), 'id="towerFabricator" class="medium"') ?>
						</div>
					</div>
					 
					<div class="field">
						<div class="label"><label for="remarks">Remarks:</label></div>
						<div class="input">
							<?php echo @form_textarea('remarks', set_value('remarks', trim($tower['remarks'])), 'id="remarks" style="width:550px; height:100px;"') ?>
						</div>
					</div>
					
					<div class="buttons">
						<input type="submit" value="Submit" />
					</div>
				</div>
			</div>
			<?php echo form_close() ?>
			
		</div>
		<!-- end:contentTower -->
		
		<!-- start:contentShelter -->
		<div id="contentShelter" title="Shelter">
			<?php echo form_open('', 'id="formShelter"') ?>
			
			<?php echo $cmd_input_shelter ?>
			<?php echo @form_hidden('siteId', set_value('siteId', $general_info['site_id'])) ?>
			
			<div class="form">
				<div class="fields">
				   
					<div class="field">
						<div class="label"><label for="kepemilikanShelter">Shelter Ownership:</label></div>
						<div class="input">
							<?php
							$dataKepemilikanShelter = get_instance()->core->view_all('t_mtr_kepemilikan_shelter', NULL, '');
							$kepemilikanShelter = array('' => '- Choose one -');
							foreach ($dataKepemilikanShelter  as $pemilik) {
								$kepemilikanShelter[$pemilik['kepemilikan_shelter_id']] = $pemilik['descr'];
							}
							echo @form_dropdown('kepemilikanShelter', $kepemilikanShelter, set_value('kepemilikanShelter', $shelter['kepemilikan_shelter']), 'id="kepemilikanShelter"');
							?>
						</div>
					</div>
				  
					<div class="field">
						<div class="label"><label for="namaPemilikShelter">Name of Shelter Owner:</label></div>
						<div class="input">
							<?php echo @form_input('namaPemilikShelter', set_value('namaPemilikShelter', trim($shelter['nama_pemilik_shelter'])), 'id="namaPemilikShelter" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="noTelpPemilikShelter">Phone of Shelter Owner:</label></div>
						<div class="input">
							<?php echo @form_input('noTelpPemilikShelter', set_value('noTelpPemilikShelter', $shelter['no_telp_pemilik_shelter']), 'id="noTelpPemilikShelter" class="medium"') ?>
						</div>
					</div>
				  
					<div class="field">
						<div class="label"><label for="shelterType">Shelter Type:</label></div>
						<div class="input">
							<?php
							$dataShelterType = get_instance()->core->view_all('t_mtr_shelter_type', NULL, '');
							$shelterType = array('' => '- Choose one -');
							foreach ($dataShelterType  as $type) {
								$shelterType[$type['shelter_type_id']] = $type['descr'];
							}
							echo @form_dropdown('shelterType', $shelterType, set_value('shelterType', $shelter['shelter_type']), 'id="shelterType"');
							?>
						</div>
					</div>
				
					<div class="field">
						<div class="label"><label for="shelterSize">Shelter Size (LxWxH):</label></div>
						<div class="input">
							<?php echo @form_input('shelterSize', set_value('shelterSize', $shelter['shelter_size']), 'id="shelterSize" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="shelterFabricator">Shelter Fabricator:</label></div>
						<div class="input">
							<?php echo @form_input('shelterFabricator', set_value('shelterFabricator', trim($shelter['shelter_fabricator'])), 'id="shelterFabricator" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="remarks">Remarks:</label></div>
						<div class="input">
							<?php echo @form_textarea('remarks', set_value('remarks', trim($shelter['remarks'])), 'id="remarks" style="width:550px; height:100px;"') ?>
						</div>
					</div>
					
					<div class="buttons">
						<input type="submit" value="Submit" />
					</div>
				</div>
			</div>
			<?php echo form_close() ?>
		</div>
		<!-- end:contentShelter -->
		
		<!-- start:contentLahan -->
		<div id="contentLahan" title="Space">
			
			<?php echo form_open('', 'id="formLahan"') ?>
			
			<?php echo $cmd_input_lahan ?>
			<?php echo @form_hidden('siteId', set_value('siteId', $general_info['site_id'])) ?>
			
			<div class="form">
				<div class="fields">
					
					<div class="field">
						<div class="label"><label for="kepemilikanLahan">Land Ownership:</label></div>
						<div class="input">
							<?php
							$kepemilikanLahan = array(0 => 'Beli', 1 => 'Sewa');
							echo @form_dropdown('kepemilikanLahan', $kepemilikanLahan, set_value('kepemilikanLahan', $lahan['kepemilikan_lahan']), 'id="kepemilikanLahan"');
							?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="jenisSuratLahan">Land Certificate Type:</label></div>
						<div class="input">
							<?php
							$dataJenisSuratLahan = get_instance()->core->view_all('t_mtr_jenis_surat_lahan', NULL,'nama');
							$jenisSuratLahan = array('' => '- Choose one -');
							foreach ($dataJenisSuratLahan as $jenis) {
								$jenisSuratLahan[$jenis['jenis_surat_lahan_id']] = $jenis['nama'];
							}
							echo @form_dropdown('jenisSuratLahan', $jenisSuratLahan, set_value('jenisSuratLahan', $lahan['jenis_surat_lahan']), 'id="jenisSuratLahan"');
							?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="noAJB">No. AJB/PKS:</label></div>
						<div class="input">
							<?php echo @form_input('noAJB', set_value('noAJB', $lahan['no_ajb']), 'id="noAJB" class="medium"') ?>
						</div>
					</div>
					  
					<div class="field">
						<div class="label"><label for="dateAJB">Date AJB/PKS:</label></div>
						<div class="input">
							<?php echo @form_input('dateAJB', set_value('dateAJB', $lahan['date_ajb']), 'id="dateAJB"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="noSuratLahan">Land Certificate Number:</label></div>
						<div class="input">
							<?php echo @form_input('noSuratLahan', set_value('noSuratLahan', $lahan['no_surat_lahan']), 'id="noSuratLahan" class="medium"') ?>
						</div>
					</div>
					  
					<div class="field">
						<div class="label"><label for="luasLahan">Land Size:</label></div>
						<div class="input">
							<?php echo @form_input('luasLahan', set_value('luasLahan', $lahan['luas_lahan']), 'id="luasLahan" class="number"') ?> <!-- M<sup>2</sup> -->
						</div>
						<div class="label" style="left:450px; vertical-align:none;"><label>m<sup>2</sup></label></div>
					</div>
					
					<div class="field">
						<div class="label"><label>Road Access:</label></div>
						<div class="label" style="left:276px"><label>Width:</label></div>
						<div class="input" style="margin:0 0 0 250px; float:left;"><?php echo @form_input('aksesJalanLebar', set_value('aksesJalanLebar', $lahan['akses_jalan_lbr']), 'id="aksesJalanLebar" class="input-mini number" style="float:none"') ?></div>
						
						<div class="label" style="left:410px"><label>x &nbsp;&nbsp;&nbsp; Height:</label></div>						
						<div class="input" style="margin:0 0 0 400px"><?php echo @form_input('aksesJalanPanjang', set_value('aksesJalanPanjang', $lahan['akses_jalan_pjg']), 'id="aksesJalanPanjang" class="input-mini number" style="float:none"') ?></div>
					</div>
					
					<div class="field">
						<div class="label"><label for="sudahBalikNama">Sudah Balik Nama:</label></div>
						<div class="input">
							<?php
							$sudahBalikNama = array(0 => 'No', 1 => 'Yes');
							echo @form_dropdown('sudahBalikNama', $sudahBalikNama, set_value('sudahBalikNama', $lahan['sudah_balik_nama']), 'id="sudahBalikNama"');
							?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="noBaru">New Number:</label></div>
						<div class="input">
							<?php echo @form_input('noBaru', set_value('noBaru', $lahan['no_baru']), 'id="noBaru" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="leaseTerm">Lease Term (year):</label></div>
						<div class="input">
							<?php echo @form_input('leaseTerm', set_value('leaseTerm', $lahan['lease_term']), 'id="leaseTerm" class=""') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="leaseStartDate">Lease Start Date:</label></div>
						<div class="input">
							<?php echo @form_input('leaseStartDate', set_value('leaseStartDate', $lahan['lease_start_date']), 'id="leaseStartDate" class="date" readonly="readonly"') ?>
						</div>
						<div class="label" style="left:478px"><a href="javascript:void(0)" onclick="clearField('leaseStartDate')">clear</a></div>
					</div>
					
					<div class="field">
						<div class="label"><label for="leaseFinishDate">Lease Finish Date:</label></div>
						<div class="input">
							<?php echo @form_input('leaseFinishDate', set_value('leaseFinishDate', $lahan['lease_finish_date']), 'id="leaseFinishDate" class="date" readonly="readonly"') ?>
						</div>
						<div class="label" style="left:478px"><a href="javascript:void(0)" onclick="clearField('leaseFinishDate')">clear</a></div>
					</div>
					
					<div class="field">
						<div class="label"><label for="namaPemilikLahan">Name of Land Ownership:</label></div>
						<div class="input">
							<?php echo @form_input('namaPemilikLahan', set_value('namaPemilikLahan', trim($lahan['nama_pemilik_lahan'])), 'id="namaPemilikLahan" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="noTelpPemilikLahan">Phone of Land Ownership:</label></div>
						<div class="input">
							<?php echo @form_input('noTelpPemilikLahan', set_value('noTelpPemilikLahan', $lahan['no_telp_pemilik_lahan']), 'id="noTelpPemilikLahan" class=""') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="contactPersonLahan">Contact Person of Land:</label></div>
						<div class="input">
							<?php echo @form_input('contactPersonLahan', set_value('contactPersonLahan', trim($lahan['contact_person_lahan'])), 'id="contactPersonLahan" class="medium"') ?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="noTelpContactPerson">Phone of Contact Person:</label></div>
						<div class="input">
							<?php echo @form_input('noTelpContactPerson', set_value('noTelpContactPerson', $lahan['no_telp_contact_person']), 'id="noTelpContactPerson" class=""') ?>
						</div>
					</div>
					
					<fieldset>
						<legend>SMG Property</legend>
						<div class="field">
							<div class="label"><label for="status">Status:</label></div>
							<div class="input">
								<?php
								$status = array(0 => 'No', 1 => 'Yes');
								echo @form_dropdown('status', $status, set_value('status', $lahan['status']), 'id="status"');
								?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="company">Company:</label></div>
							<div class="input">
								<?php echo @form_input('company', set_value('company', trim($lahan['company'])), 'id="company" class="medium"') ?>
							</div>
						</div>
					</fieldset>
					
					<div class="buttons">
						<input type="submit" value="Submit" />
					</div>
				</div>
			</div>
			
			<?php echo form_close() ?> 
		</div>
		<!-- end:contentLahan -->
		
		<!-- start:contentPerijinan -->
		<div id="contentPerijinan" title="Permission">
			<?php echo form_open('', 'id="formPerijinan"') ?>
			
			<?php echo $cmd_input_perijinan ?>
			<?php echo @form_hidden('siteId', set_value('siteId', $general_info['site_id'])) ?>
			
			<div class="form">
				<div class="fields">					
					<div class="field">
						<div class="label"><label for="iwNeeded">IW Needed:</label></div>
						<div class="input">
							<?php
							$iwNeeded = array(0 => 'No', 1 => 'Yes');
							echo @form_dropdown('iwNeeded', $iwNeeded, set_value('iwNeeded', $perijinan['iw_needed']), 'id="iwNeeded"');
							?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="iwDate">IW Date:</label></div>
						<div class="input">
							<?php echo @form_input('iwDate', set_value('iwDate', $perijinan['iw_date']), 'id="iwDate" class="date" readonly="readonly"') ?>
						</div>
						<div class="label" style="left:478px"><a href="javascript:void(0)" onclick="clearField('iwDate')">clear</a></div>
					</div>
					
					<div class="field">
						<div class="label"><label for="retribusi">Retribution:</label></div>
						<div class="input">
							<?php
							$retribusi = array(0 => 'No', 1 => 'Yes');
							echo @form_dropdown('retribusi', $retribusi, set_value('retribusi', $perijinan['retribusi']), 'id="retribusi"');
							?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="biayaRetribusi">Retribution Fee:</label></div>
						<div class="input">
							<?php echo @form_input('biayaRetribusi', set_value('biayaRetribusi', trim($perijinan['biaya_retribusi'])), 'id="biayaRetribusi" class="currency"') ?>
						</div>
					</div>
					
					<fieldset>
						<legend>HO Info</legend>
						
						<div class="field">
							<div class="label"><label for="hoNumber">HO Number:</label></div>
							<div class="input">
								<?php echo @form_input('hoNumber', set_value('hoNumber', trim($perijinan['ho_number'])), 'id="hoNumber" class="medium"') ?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="hoDate">HO Date:</label></div>
							<div class="input">
								<?php echo @form_input('hoDate', set_value('hoDate', $perijinan['ho_date']), 'id="hoDate" class="date" readonly="readonly"') ?>
							</div>
							<div class="label" style="left:478px"><a href="javascript:void(0)" onclick="clearField('hoDate')">clear</a></div>
						</div>
						
						<div class="field">
							<div class="label"><label for="hoExpired">HO Expired:</label></div>
							<div class="input">
								<?php echo @form_input('hoExpired', set_value('hoExpired', $perijinan['ho_expired']), 'id="hoExpired" class="date" readonly="readonly"') ?>
							</div>
							<div class="label" style="left:478px"><a href="javascript:void(0)" onclick="clearField('hoExpired')">clear</a></div>
						</div>
					</fieldset>
					
					<fieldset>
						<legend>PBB</legend>
						
						<div class="field">
							<div class="label"><label for="nomorPBB">PBB Number:</label></div>
							<div class="input">
								<?php echo @form_input('nomorPBB', set_value('nomorPBB', $perijinan['nomor_pbb']), 'id="nomorPBB" class="medium"') ?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="atasNama">Name:</label></div>
							<div class="input">
								<?php echo @form_input('atasNama', set_value('atasNama', trim($perijinan['atas_nama'])), 'id="atasNama" class="medium"') ?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="jatuhTempo">Due Date:</label></div>
							<div class="input">
								<?php echo @form_input('jatuhTempo', set_value('jatuhTempo', $perijinan['jatuh_tempo']), 'id="jatuhTempo" class="date" readonly="readonly"') ?>
							</div>
							<div class="label" style="left:478px"><a href="javascript:void(0)" onclick="clearField('jatuhTempo')">clear</a></div>
						</div>
						
						<div class="field">
							<div class="label"><label for="nilaiPBB">Nilai PBB:</label></div>
							<div class="input">
								<?php echo @form_input('nilaiPBB', set_value('nilaiPBB', $perijinan['nilai_pbb']), 'id="nilaiPBB" class=""') ?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="picPBB">PIC PBB:</label></div>
							<div class="input">
								<?php
								$dataPICPBB = get_instance()->core->view_all('t_mtr_pic_pbb', NULL, 'descr');
								$picPBB = array('' => '- Choose one -');
								foreach ($dataPICPBB as $pic) {
									$picPBB[$pic['pic_pbb_id']] = $pic['descr'];
								}
								echo @form_dropdown('picPBB', $picPBB, set_value('picPBB', $perijinan['pic_pbb']), 'id="picPBB"');
								?>
							</div>
						</div>
					</fieldset>
					
					<fieldset>
						<legend>IMB</legend>
						
						<div class="field">
							<div class="label"><label for="nomorIMB">IMB Number:</label></div>
							<div class="input">
								<?php echo @form_input('nomorIMB', set_value('nomorIMB', trim($perijinan['nilai_pbb'])), 'id="nomorIMB" class="medium"') ?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="imbDate">Date:</label></div>
							<div class="input">
								<?php echo @form_input('imbDate', set_value('imbDate', $perijinan['date']), 'id="imbDate" class="date" readonly="readonly"') ?>
							</div>
							<div class="label" style="left:478px"><a href="javascript:void(0)" onclick="clearField('imbDate')">clear</a></div>
						</div>
						
						<div class="field">
							<div class="label"><label for="imbExpired">Expired:</label></div>
							<div class="input">
								<?php echo @form_input('imbExpired', set_value('imbExpired', $perijinan['expired']), 'id="imbExpired" class="date" readonly="readonly"') ?>
							</div>
							<div class="label" style="left:478px"><a href="javascript:void(0)" onclick="clearField('imbExpired')">clear</a></div>
						</div>
					</fieldset>
					
					<fieldset>
						<legend>Rekomendasi Ketinggian Tower (RKT)</legend>
						
						<div class="field">
							<div class="label"><label for="rktNumber">RKT Number:</label></div>
							<div class="input">
								<?php echo @form_input('rktNumber', set_value('rktNumber', trim($perijinan['rkt_number'])), 'id="rktNumber" class="medium"') ?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="rktDate">RKT Date:</label></div>
							<div class="input">
								<?php echo @form_input('rktDate', set_value('rktDate', $perijinan['rkt_date']), 'id="rktDate" class="date" readonly="readonly"') ?>
							</div>
							<div class="label" style="left:478px"><a href="javascript:void(0)" onclick="clearField('rktDate')">clear</a></div>
						</div>
						
						<div class="field">
							<div class="label"><label for="remarks">Remarks:</label></div>
							<div class="input">
								<?php echo @form_textarea('remarks', set_value('remarks', trim($perijinan['remarks'])), 'id="remarks" style="width:550px; height:100px;"') ?>
							</div>
						</div>
					</fieldset>
					
					<div class="buttons">
						<input type="submit" value="Submit" />
					</div>
				
				</div>
			</div>
			<?php echo form_close() ?>
		</div>
		<!-- end:contentPerijinan -->
		
		<!-- start:contentTenancy -->
		<div id="contentTenancy" title="Tenancy">
			<?php echo form_open('', 'id="formTenancy"') ?>
			
			<?php echo $cmd_input_tenancy ?>
			<?php echo @form_hidden('siteId', set_value('siteId', $general_info['site_id'])) ?>
			
			<div class="form">
				<div class="fields">
					<fieldset>
						<legend>Colloc Sell</legend>
						
						<div class="field">
							<div class="label"><label for="availableForRent">Available for Rent:</label></div>
							<div class="input">
								<?php
								$availableForRent = array(0 => 'No', 1 => 'Yes');
								echo @form_dropdown('availableForRent', $availableForRent, set_value('availableForRent', $tenancy_sell[0]['available_for_rent']), 'id="availableForRent"');
								?>
							</div>
						</div>
						
						<?php
						if (get_instance()->uri->segment(2) == 'edit' && $tenancy_sell) {
						
							$sellcounter = count($tenancy_sell);
							$i = 1;
							foreach ($tenancy_sell as $sell) {
								$loop = '';
								if ($i == 1) {
									$loop = $i.'st';
								} elseif ($i == 2) {
									$loop = $i.'nd';
								} elseif ($i == 3) {
									$loop = $i.'rd';
								} else {
									$loop = $i.'th';
								}
						?>						
						<div class="field" id="fieldTenantCollocSell-<?php echo $i ?>">
							<div class="label"><label for="tenantCollocSell-<?php echo $i ?>">Tenant <?php echo $loop ?>:</label></div>
							<div class="input">
								<?php //echo @form_input('tenantCollocSell[]', set_value('tenantCollocSell', trim($item['name'])), 'id="tenantCollocSell-'.$i.'" class="tenant-data" size="40"') ?>
								<?php
								$tenantCollocSell = array('' => '- Choose one -');
								$dataTenantCollocSell = get_instance()->core->view_all('t_mtr_tenant', array('status' => 1), 'tenant_name');
								foreach ($dataTenantCollocSell as $tenant) {
									$tenantCollocSell[$tenant['tenant_id']] = $tenant['tenant_name'];
								}
								echo @form_dropdown('tenantCollocSell[]', $tenantCollocSell, set_value('tenantCollocSell[]', $sell['tenant_id']), 'id="tenantCollocSell-'.$i.'" style="float:left"');
								?>
							</div>
							
							<div class="label" style="left:650px"><label for="tenantDateCollocSell-<?php echo $i ?>">Date:</label></div>
							<div class="input" style="margin:0 0 0 650px">
								<?php echo @form_input('tenantDateCollocSell[]', set_value('tenantDateCollocSell', $sell['tenancy_date']), 'id="tenantDateCollocSell-'.$i.'" class="date" readonly="readonly"') ?>
							</div>
							<div class="label" style="left:930px"><a href="javascript:void(0)" onclick="clearField('tenantDateCollocSell-<?php echo $i ?>')">clear</a></div>
						</div>
						
						<!--
						<div class="field">
							<div class="label"><label for="tenantDateCollocSell-<?php echo $i ?>">Tenant <?php echo $loop ?> Date</label></div>
							<div class="input">
								<?php echo @form_input('tenantDateCollocSell[]', set_value('tenantDateCollocSell', $item['date']), 'id="tenantDateCollocSell-'.$i.'" class="date"') ?>
							</div>
						</div>
						-->
						<?php
								$i++;
							}
						} else { // default one
						?>
						
						<div class="field" id="fieldTenantCollocSell-1">
							<div class="label"><label for="tenantCollocSell-1">Tenant 1st:</label></div>
							<div class="input">
								<?php //echo @form_input('tenantCollocSell[]', set_value('tenantCollocSell', ''), 'id="tenantCollocSell-1" class="tenant-data" size="40"') ?>
								<?php
								$tenantCollocSell = array('' => '- Choose one -');
								$dataTenantCollocSell = get_instance()->core->view_all('t_mtr_tenant', array('status' => 1), 'tenant_name');
								foreach ($dataTenantCollocSell as $tenant) {
									$tenantCollocSell[$tenant['tenant_id']] = $tenant['tenant_name'];
								}
								echo @form_dropdown('tenantCollocSell[]', $tenantCollocSell, '', 'id="tenantCollocSell-1" style="float:left"');
								?>
							</div>
							
							<div class="label" style="left:650px"><label for="tenantDateCollocSell-1">Date:</label></div>
							<div class="input" style="margin:0 0 0 650px">
								<?php echo @form_input('tenantDateCollocSell[]', set_value('tenantDateCollocSell', ''), 'id="tenantDateCollocSell-1" class="date" readonly="readonly"') ?>
							</div>
							<div class="label" style="left:930px"><a href="javascript:void(0)" onclick="clearField('tenantDateCollocSell-1')">clear</a></div>
						</div>
						
						<?php } ?>
						
						<div id="addCollocSell" class="field">
							<div class="input">[ <a href="javascript:void(0)" onclick="addCollocSell()">Add more</a> ]</div>
						</div>
						
					</fieldset>
					
					<fieldset>
						<legend>Colloc Buy</legend>
						
						<div class="field">
							<div class="label"><label for="seqNumberOfTenant">Seq. Number of Tenant:</label></div>
							<div class="input">
								<?php echo @form_input('seqNumberOfTenant', set_value('seqNumberOfTenant', $tenancy_buy[0]['seq_number']), 'id="seqNumberOfTenant" class="medium"') ?>
							</div>
						</div>
						
						<?php
						if (get_instance()->uri->segment(2) == 'edit' && $tenancy_buy) {
						
							$buycounter = count($tenancy_buy);
							$i = 1;
							foreach ($tenancy_buy as $buy) {
								$loop = '';
								if ($i == 1) {
									$loop = $i.'st';
								} elseif ($i == 2) {
									$loop = $i.'nd';
								} elseif ($i == 3) {
									$loop = $i.'rd';
								} else {
									$loop = $i.'th';
								}
						?>
						<div class="field" id="fieldTenantCollocBuy-<?php echo $i ?>">
							<div class="label"><label for="tenantCollocBuy-<?php echo $i ?>">Tenant <?php echo $loop ?>:</label></div>
							<div class="input">
								<?php //echo @form_input('tenantCollocBuy[]', set_value('tenantCollocBuy', trim($item['name'])), 'id="tenantCollocBuy-'.$i.'" class="tenant-data" size="40"') ?>
								<?php
								$tenantCollocBuy = array('' => '- Choose one -');
								$dataTenantCollocBuy = get_instance()->core->view_all('t_mtr_tenant', array('status' => 1), 'tenant_name');
								foreach ($dataTenantCollocBuy as $tenant) {
									$tenantCollocBuy[$tenant['tenant_id']] = $tenant['tenant_name'];
								}
								echo @form_dropdown('tenantCollocBuy[]', $tenantCollocBuy, set_value('tenantCollocBuy[]', $buy['tenant_id']), 'id="tenantCollocBuy-'.$i.'" style="float:left"');
								?>
							</div>
							
							<div class="label" style="left:650px"><label for="tenantDateCollocBuy-<?php echo $i ?>">Date:</label></div>
							<div class="input" style="margin:0 0 0 650px">
								<?php echo @form_input('tenantDateCollocBuy[]', set_value('tenantDateCollocBuy', $buy['tenancy_date']), 'id="tenantDateCollocBuy-'.$i.'" class="date tenant-data" readonly="readonly"') ?>
							</div>
							<div class="label" style="left:930px"><a href="javascript:void(0)" onclick="clearField('tenantDateCollocBuy-<?php echo $i ?>')">clear</a></div>
						</div>
						
						<!--
						<div class="field">
							<div class="label"><label for="tenantDateCollocBuy-<?php echo $i ?>">Tenant <?php echo $loop ?> Date</label></div>
							<div class="input">
								<?php echo @form_input('tenantDateCollocBuy[]', set_value('tenantDateCollocBuy', $item['date']), 'id="tenantDateCollocBuy-'.$i.'" class="date"') ?>
							</div>
						</div>
						-->
						<?php
								$i++;
							}
						} else { // default one
						?>
						
						<div class="field" id="fieldTenantCollocBuy-1">
							<div class="label"><label for="tenantCollocBuy-1">Tenant 1st:</label></div>
							<div class="input">
								<?php //echo @form_input('tenantCollocBuy[]', set_value('tenantCollocBuy', ''), 'id="tenantCollocBuy-1" class="tenant-data" size="40"') ?>
								<?php
								$tenantCollocBuy = array('' => '- Choose one -');
								$dataTenantCollocBuy = get_instance()->core->view_all('t_mtr_tenant', array('status' => 1), 'tenant_name');
								foreach ($dataTenantCollocBuy as $tenant) {
									$tenantCollocBuy[$tenant['tenant_id']] = $tenant['tenant_name'];
								}
								echo @form_dropdown('tenantCollocBuy[]', $tenantCollocBuy, '', 'id="tenantCollocBuy-1" style="float:left"');
								?>
							</div>
							
							<div class="label" style="left:650px"><label for="tenantDateCollocBuy-1">Date:</label></div>
							<div class="input" style="margin:0 0 0 650px">
								<?php echo @form_input('tenantDateCollocBuy[]', set_value('tenantDateCollocBuy', ''), 'id="tenantDateCollocBuy-1" class="date" readonly="readonly"') ?>
							</div>
							<div class="label" style="left:930px"><a href="javascript:void(0)" onclick="clearField('tenantDateCollocBuy-1')">clear</a></div>
						</div>
						
						<?php } ?>
						
						<div id="addCollocBuy" class="field">
							<div class="input">[ <a href="javascript:void(0)" onclick="addCollocBuy()">Add more</a> ]</div>
						</div>
						
					</fieldset>
					
					<div class="buttons">
						<input type="submit" value="Submit" />
					</div>
				</div>
			</div>
			<?php echo form_close() ?>
		</div>
		<!-- end:contentTenancy -->
		
		<!-- start:contentAC -->
		<div id="contentAC" title="Air Conditioner (AC)">
			<?php echo form_open('', 'id="formAC"') ?>
			
			<?php echo $cmd_input_ac ?>
			<?php echo @form_hidden('siteId', set_value('siteId', $general_info['site_id'])) ?>
			
			<div class="form">
				<div class="fields">
					<fieldset>
						<legend>AC1</legend>
						
						<div class="field">
							<div class="label"><label for="brandAC1">Brand:</label></div>
							<div class="input">
								<?php
								$dataBrandAc1 = get_instance()->core->view_all('t_mtr_ac_brand', NULL, 'nama');
								$brandAC1 = array('' => '- Choose one -');
								foreach ($dataBrandAc1 as $brand1) {
									$brandAC1[$brand1['ac_brand_id']] = $brand1['nama'];
								}
								echo @form_dropdown('brandAC1', $brandAC1, set_value('brandAC1', $ac['ac1_brand']), 'id="brandAC1"');
								?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="typeAC1">Type / Model:</label></div>
							<div class="input">
								<?php echo @form_input('typeAC1', set_value('typeAC1', $ac['ac1_type']), 'id="typeAC1" class="medium"') ?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="capacityAC1">Capacity:</label></div>
							<div class="input">
								<?php
								$dataCapacity1 = get_instance()->core->view_all('t_mtr_ac_capacity', NULL, 'nama');
								$capacityAC1 = array('' => '- Choose one -');
								foreach ($dataCapacity1 as $capacity1) {
									$capacityAC1[$capacity1['ac_capacity_id']] = $capacity1['nama'];
								}
								echo @form_dropdown('capacityAC1', $capacityAC1, set_value('capacityAC1', $ac['ac1_capacity']), 'id="capacityAC1"');
								?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="serialNumberAC1">Serial Number:</label></div>
							<div class="input">
								<?php echo @form_input('serialNumberAC1', set_value('serialNumberAC1', $ac['ac1_serial']), 'id="serialNumberAC1" class="medium"') ?>
							</div>
						</div>
					</fieldset>
					
					<fieldset>
						<legend>AC2</legend>
						
						<div class="field">
							<div class="label"><label for="brandAC2">Brand:</label></div>
							<div class="input">
								<?php
								$dataBrandAc2 = get_instance()->core->view_all('t_mtr_ac_brand', NULL, 'nama');
								$brandAC2 = array('' => '- Choose one -');
								foreach ($dataBrandAc2 as $brand2) {
									$brandAC2[$brand2['ac_brand_id']] = $brand2['nama'];
								}
								echo @form_dropdown('brandAC2', $brandAC2, set_value('brandAC2', $ac['ac2_brand']), 'id="brandAC2"');
								?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="typeAC2">Type / Model:</label></div>
							<div class="input">
								<?php echo @form_input('typeAC2', set_value('typeAC2', $ac['ac2_type']), 'id="typeAC2" class="medium"') ?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="capacityAC2">Capacity:</label></div>
							<div class="input">
								<?php
								$dataCapacity2 = get_instance()->core->view_all('t_mtr_ac_capacity', NULL, 'nama');
								$capacityAC2 = array('' => '- Choose one -');
								foreach ($dataCapacity2 as $capacity2) {
									$capacityAC2[$capacity2['ac_capacity_id']] = $capacity2['nama'];
								}
								echo @form_dropdown('capacityAC2', $capacityAC2, set_value('capacityAC2', $ac['ac2_capacity']), 'id="capacityAC2"');
								?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="serialNumberAC2">Serial Number:</label></div>
							<div class="input">
								<?php echo @form_input('serialNumberAC2', set_value('serialNumberAC2', $ac['ac2_serial']), 'id="serialNumberAC2" class="medium"') ?>
							</div>
						</div>
					</fieldset>
					
					<fieldset>
						<legend>AC3</legend>
						
						<div class="field">
							<div class="label"><label for="brandAC3">Brand:</label></div>
							<div class="input">
								<?php
								$dataBrandAc3 = get_instance()->core->view_all('t_mtr_ac_brand', NULL, 'nama');
								$brandAC3 = array('' => '- Choose one -');
								foreach ($dataBrandAc3 as $brand3) {
									$brandAC3[$brand3['ac_brand_id']] = $brand3['nama'];
								}
								echo @form_dropdown('brandAC3', $brandAC3, set_value('brandAC3', $ac['ac3_brand']), 'id="brandAC3"');
								?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="typeAC3">Type / Model:</label></div>
							<div class="input">
								<?php echo @form_input('typeAC3', set_value('typeAC3', $ac['ac3_type']), 'id="typeAC3" class="medium"') ?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="capacityAC3">Capacity:</label></div>
							<div class="input">
								<?php
								$dataCapacity3 = get_instance()->core->view_all('t_mtr_ac_capacity', NULL, 'nama');
								$capacityAC3 = array('' => '- Choose one -');
								foreach ($dataCapacity3 as $capacity3) {
									$capacityAC3[$capacity3['ac_capacity_id']] = $capacity3['nama'];
								}
								echo @form_dropdown('capacityAC3', $capacityAC3, set_value('capacityAC3', $ac['ac3_capacity']), 'id="capacityAC3"');
								?>
							</div>
						</div>
						
						<div class="field">
							<div class="label"><label for="serialNumberAC3">Serial Number:</label></div>
							<div class="input">
								<?php echo @form_input('serialNumberAC3', set_value('serialNumberAC3', $ac['ac2_serial']), 'id="serialNumberAC3" class="medium"') ?>
							</div>
						</div>
					</fieldset>
					
					<div class="field">
						<div class="label"><label for="remarks">Remarks:</label></div>
						
						<div class="input">
							<?php echo @form_textarea('remarks', set_value('remarks', trim($ac['remarks'])), 'id="remarks" style="width:550px; height:100px;"') ?>
						</div>
					</div>
					
					<div class="buttons">
						<input type="submit" value="Submit" />
					</div>
				</div>
			</div>
			
			<?php echo form_close() ?>
		</div>
		<!-- end:contentAC -->
	
		<!-- start:contentEquipmet -->
		<div id="contentEquipment" title="Equipment">
			<?php echo form_open('', 'id="formEquipment"') ?>
			
			<?php echo $cmd_input_equipment ?>
			<?php echo @form_hidden('siteId', set_value('siteId', $general_info['site_id'])) ?>
			
			<div class="form">
				<div class="fields">
				
					<fieldset>
						<legend>Antena BTS</legend>
						
						<div class="field">
							<div class="label"><label for="jumlahAntenaBTS">Jumlah Antena BTS:</label></div>
							<div class="input"><?php echo @form_input('jumlahAntenaBTS', set_value('jumlahAntenaBTS', $equipment['jumlah_antena_bts']), 'id="jumlahAntenaBTS" class="just-number"') ?></div>
						
							<div class="label" style="left:550px"><label for="ketinggianAntenaBTS">Ketinggian Antena BTS:</label></div>
							<div class="input" style="margin:0 0 0 650px"><?php echo @form_input('ketinggianAntenaBTS', set_value('ketinggianAntenaBTS', $equipment['ketinggian_antena_bts']), 'id="ketinggianAntenaBTS" class="just-number"') ?></div>
						</div>
						
						<div class="field">
							<div class="label"><label for="azimuthBTS">Azimuth:</label></div>
							<div class="input"><?php echo @form_input('azimuthBTS', set_value('azimuthBTS', $equipment['azimuth_bts']), 'id="azimuthBTS" class="just-number"') ?></div>
						</div>
					</fieldset>
					
					<fieldset>
						<legend>Antena MW</legend>
						<div class="field">
							<div class="label"><label for="jumlahAntenaMW">Jumlah Antena MW:</label></div>
							<div class="input"><?php echo @form_input('jumlahAntenaMW', set_value('jumlahAntenaMW', $equipment['jumlah_antena_mw']), 'id="jumlahAntenaMW" class="just-number"') ?></div>
						
							<div class="label" style="left:550px"><label for="ketinggianAntenaMW">Ketinggian Antena MW:</label></div>
							<div class="input" style="margin:0 0 0 650px"><?php echo @form_input('ketinggianAntenaMW', set_value('ketinggianAntenaMW', $equipment['ketinggian_antena_mw']), 'id="ketinggianAntenaMW" class="just-number"') ?></div>
						</div>
						
						<div class="field">
							<div class="label"><label for="azimuthMW">Azimuth:</label></div>
							<div class="input"><?php echo @form_input('azimuthMW', set_value('azimuthMW', $equipment['azimuth_mw']), 'id="azimuthMW" class="just-number"') ?></div>
						
							<div class="label" style="left:550px"><label for="diameterMW">Diameter:</label></div>
							<div class="input" style="margin:0 0 0 650px"><?php echo @form_input('diameterMW', set_value('diameterMW', $equipment['diameter_mw']), 'id="diameterMW" class="just-number"') ?></div>
						</div>
					</fieldset>
					
					<div class="field">
						<div class="label"><label for="farEnd">Far End:</label></div>
						<div class="input"><?php echo @form_input('farEnd', set_value('farEnd', $equipment['far_end']), 'id="farEnd" class=""') ?></div>
					</div>
					
					<div class="field">
						<div class="label"><label for="siteClassificationTransmisi">Site Classification Transmisi:</label></div>
						<div class="input">
							<?php
							$siteClassificationTransmisi = array('' => '- Choose one -');
							echo @form_dropdown('siteClassificationTransmisi', $siteClassificationTransmisi, set_value('siteClassificationTransmisi', $equipment['site_classification_transmisi']), 'id="siteClassificationTransmisi" class=""');
							?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="morphology">Morphology:</label></div>
						<div class="input">
							<?php
							$morphology = array('' => '- Choose one -');
							echo @form_dropdown('morphology', $morphology, set_value('morphology', $equipment['morphology']), 'id="morphology" class=""');
							?>
						</div>
					</div>
					
					<div class="field">
						<div class="label"><label for="btsMode">BTS Mode:</label></div>
						<div class="input">
							<?php
							$morphology = array('' => '- Choose one -');
							echo @form_dropdown('morphology', $morphology, set_value('morphology', $equipment['morphology']), 'id="morphology" class=""');
							?>
						</div>
					</div>
					
					<div class="buttons">
						<input type="submit" value="Submit" />
					</div>
				
				</div>
			</div>
			
			<?php echo form_close() ?>
		</div>
		<!-- end:contentEquipment -->
	
	</div>
	<!-- end:siteInfo -->
	
</div>

<script src="<?php echo base_url('/assets/js/jquery-1.7.1.js') ?>"></script>
<script src="<?php echo base_url('/assets/js/jquery-ui-1.8.16/jquery-ui-1.8.16.custom.min.js') ?>"></script>

<?php
// swd
function mylabel($labelFor,$label) {
	//return '<div class="label"><label for="'. $labelFor .'">'. $label .'</label></div>';
	//echo '<div class="label"><label for="remarks">Remarks</label></div>';
	
	return '<div class="label">
	<label for="'.$labelFor.'">'.$label.'</label>
	</div>';
}

?>

<script><!--

var formSubmit = function(form) {
	
	<?php if (get_instance()->uri->segment(2) == 'add') { ?>
	var url = '<?php echo site_url('/site_info/add') ?>';
	<?php } else { ?>
	var url = '<?php echo site_url('/site_info/edit/'.get_instance()->uri->segment(3)) ?>';
	<?php } ?>
	
	$.ajax({
		url: url,
		data: $(form).serialize(),
		type: 'POST',
		dataType: 'json',
		beforeSend: function() {
			siteOverlay.top = '10px';
			siteOverlay.create();
		},
		success: function(json) {
			var alertError = document.getElementsByClassName('message-error');
			for (var i = 0; i < alertError.length; i++) {
				alertError[i].parentNode.removeChild(alertError[i]);
			}
			
			var alertSuccess = document.getElementsByClassName('message-success');
			for (var i = 0; i < alertSuccess.length; i++) {
				alertSuccess[i].parentNode.removeChild(alertSuccess[i]);
			}
			
			var siteId = document.getElementsByName('siteId');
			for (var i = 0; i < siteId.length; i++) {
				siteId[i].value = json['site_id'];
			}
		
			if (json['error']) {
				var message = '\
					<div class="message-error" style="padding:10px; margin-bottom:10px;">';
						message += '<ul>';
						for (var i = 0; i < json['message'].length; i++) {
							message += '<li>- ' + json['message'][i] + '</li>';
						}
						message += '</ul>';
					message += '</div>';
				
				$('#siteInfo').prepend(message);
				$('#siteInfo').css('height', 'auto');
			} else {
				var message = '\
					<div class="message-success" style="padding:10px; margin-bottom:10px;">' + json['message'] + '</div>';
				
				$('#siteInfo').prepend(message);
				$('#siteInfo').css('height', 'auto');
			}
		},
		complete: function() {
			siteOverlay.remove();
		}
	});
};

document.getElementById('formGeneralInfo').onsubmit = function() {
	formSubmit(this);
	window.scroll(0, 0);
	
	return false;
};

document.getElementById('formSiteKeepers').onsubmit = function() {
	currencyOnSubmit();
	
	formSubmit(this);
	window.scroll(0, 0);
	
	return false;
};

document.getElementById('formPLN').onsubmit = function() {
	numberOnSubmit();
	
	formSubmit(this);
	window.scroll(0, 0);
	
	return false;
};

document.getElementById('formTower').onsubmit = function() {
	formSubmit(this);
	window.scroll(0, 0);
	
	return false;
};

document.getElementById('formShelter').onsubmit = function() {
	formSubmit(this);
	window.scroll(0, 0);
	
	return false;
};

document.getElementById('formLahan').onsubmit = function() {
	formSubmit(this);
	window.scroll(0, 0);
	
	return false;
};

document.getElementById('formPerijinan').onsubmit = function() {
	formSubmit(this);
	window.scroll(0, 0);
	
	return false;
};

document.getElementById('formTenancy').onsubmit = function() {
	formSubmit(this);
	window.scroll(0, 0);
	
	return false;
};

document.getElementById('formAC').onsubmit = function() {
	formSubmit(this);
	window.scroll(0, 0);
	
	return false;
};

document.getElementById('propinsi').onchange = function() {
	
	$.ajax({
		url: '<?php echo site_url('/site_info/add') ?>',
		type: 'GET',
		data: { cmd: 'GET_KABUPATEN', propinsi_id: this.value },
		dataType: 'json',
		success: function(json) {
			var html = '<option value="">- Choose one -</option>';
			for (var i = 0; i < json.length; i++) {
				html += '<option value="' + json[i]['id'] + '">' + json[i]['name'] + '</option>';
			}
			document.getElementById('kabupaten').innerHTML = html;
			document.getElementById('kecamatan').innerHTML = '<option value="">- Choose one -</option>';
		}
	});	
};

document.getElementById('kabupaten').onchange = function() {
	
	$.ajax({
		url: '<?php echo site_url('/site_info/add') ?>',
		type: 'GET',
		data: { cmd: 'GET_KECAMATAN', kabupaten_id: this.value },
		dataType: 'json',
		success: function(json) {
			var html = '<option value="">- Choose one -</option>';
			for (var i = 0; i < json.length; i++) {
				html += '<option value="' + json[i]['id'] + '">' + json[i]['name'] + '</option>';
			}
			document.getElementById('kecamatan').innerHTML = html;
		}
	});
};

<?php if (get_instance()->uri->segment(2) == 'edit' && isset($sellcounter)) { ?>
var collocSellCounter = <?php echo ($sellcounter + 1) ?>;
<?php } else { ?>
var collocSellCounter = 2;
<?php } ?>

var addCollocSell = function() {
	var labelTenantSell = 'Tenant ';
	var labelTenantDateSell = 'Date';
	
	if (collocSellCounter == 1) {
		labelTenantSell += '1st';
	} else if (collocSellCounter == 2) {
		labelTenantSell += '2nd';
	} else if (collocSellCounter == 3) {
		labelTenantSell += '3rd';
	} else {
		labelTenantSell += collocSellCounter + 'th';
	}
		
	<?php
	$tenantCollocSell = array('' => '- Choose one -');
	$dataTenantCollocSell = get_instance()->core->view_all('t_mtr_tenant', array('status' => 1), 'tenant_name');
	?>
	
	var html = '\
		<div class="field" id="fieldTenantCollocSell-' + collocSellCounter + '">\
			<div class="label"><label for="tenantCollocSell-' + collocSellCounter + '">' + labelTenantSell + ':</label></div>\
			<div class="input">\
				<select name="tenantCollocSell[]" id="tenantCollocSell-' + collocSellCounter + '" style="float:left">\
					<option value="0">- Choose one -</option>\
					<?php
					foreach ($dataTenantCollocSell as $tenant) {
						echo '<option value="'.$tenant['tenant_id'].'">'.$tenant['tenant_name'].'</option>';
					}
					?>\
				</select>\
			</div>\
			\
			<div class="label" style="left:650px"><label for="tenantDateCollocSell-' + collocSellCounter + '">' + labelTenantDateSell + ':</label></div>\
			<div class="input" style="margin:0 0 0 650px"><input type="text" name="tenantDateCollocSell[]" id="tenantDateCollocSell-' + collocSellCounter + '" class="date" autocomplete="off" readonly="readonly" /></div>\
			\
			<div class="label" style="left:930px"><a href="javascript:void(0)" onclick="clearField(\'tenantDateCollocSell-' + collocSellCounter + '\')">clear</a></div>\
		</div>\
	';
	
	$('#addCollocSell').before(html);
	
	$('.date').datepicker({dateFormat: 'yy-mm-dd'});
	
	collocSellCounter++;
};

<?php if (get_instance()->uri->segment(2) == 'edit' && isset($buycounter)) { ?>
var collocBuyCounter = <?php echo ($buycounter + 1) ?>;
<?php } else { ?>
var collocBuyCounter = 2;
<?php } ?>

var addCollocBuy = function() {
	var labelTenantBuy = 'Tenant ';
	var labelTenantDateBuy = 'Date';
	
	if (collocBuyCounter == 1) {
		labelTenantBuy += '1st';
	} else if (collocBuyCounter == 2) {
		labelTenantBuy += '2nd';
	} else if (collocBuyCounter == 3) {
		labelTenantBuy += '3rd';
	} else {
		labelTenantBuy += collocBuyCounter + 'th';
	}
	
	<?php
	$tenantCollocBuy = array('' => '- Choose one -');
	$dataTenantCollocBuy = get_instance()->core->view_all('t_mtr_tenant', array('status' => 1), 'tenant_name');
	?>
	
	var html = '\
		<div class="field" id="fieldTenantCollocBuy-' + collocBuyCounter + '">\
			<div class="label"><label for="tenantCollocBuy-' + collocBuyCounter + '">' + labelTenantBuy + ':</label></div>\
			<div class="input">\
				<select name="tenantCollocBuy[]" id="tenantCollocBuy-' + collocBuyCounter + '" style="float:left">\
					<option value="0">- Choose one -</option>\
					<?php
					foreach ($dataTenantCollocBuy as $tenant) {
						echo '<option value="'.$tenant['tenant_id'].'">'.$tenant['tenant_name'].'</option>';
					}
					?>\
				</select>\
			</div>\
			\
			<div class="label" style="left:650px"><label for="tenantDateCollocBuy-' + collocBuyCounter + '">' + labelTenantDateBuy + ':</label></div>\
			<div class="input" style="margin:0 0 0 650px"><input type="text" name="tenantDateCollocBuy[]" id="tenantDateCollocBuy-' + collocBuyCounter + '" class="date" autocomplete="off" readonly="readonly" /></div>\
			\
			<div class="label" style="left:930px"><a href="javascript:void(0)" onclick="clearField(\'tenantDateCollocBuy-' + collocBuyCounter + '\')">clear</a></div>\
		</div>\
	';
	
	$('#addCollocBuy').before(html);
	
	$('.date').datepicker({dateFormat: 'yy-mm-dd'});
	
	collocBuyCounter++;
};

/*
var initTenantData = function() {
	var tenantData = document.getElementsByName('tenantCollocSell[]');
	for (var i = 0; i < tenantData.length; i++) {
		$(tenantData[i]).autocomplete({
			minLength: 2,
			source: function(req, resp) {
				$.ajax({
					url: '<?php echo site_url('/site_info/add') ?>',
					dataType: 'json',
					type: 'GET',
					data: { cmd: 'GET_TENANT', key: req.term },
					beforeSend: function() {},
					success: function(json) {
						resp(json.data);
					},
					complete: function() {}
				});
			},
			open: function(event, ui) {
				var  acData = $(this).data('autocomplete');
				var termTemplate = '<strong>%s</strong>';
				
				acData.menu.element.find('a').each(function() {
					var me = $(this);
					var regex = new RegExp(acData.term, "gi");
					me.html( me.text().replace(regex, function (matched) {
						return termTemplate.replace('%s', matched);
					}) );
				});
			},
			select: function(event, ui) {
				if (typeof(document.getElementsByName('tenantCollocSell[]')[i]) != 'undefined') {
				document.getElementsByName('tenantCollocSell[]')[i].value = ui.item.id;
				}
				
			},
			change: function(event, ui) {
				if (ui.item == null || ui.item.id == '') {
					$(this).val('');
				}
			}
		});console.log(i);
	}
};
initTenantData();
*/

//--></script>

<script><!--

$(function() {
	
	$('.date').datepicker({dateFormat: 'yy-mm-dd'});
	
	$('#cmePartnerName').autocomplete({
		minLength: 2,
      	source: function(req, resp) {
			$.ajax({
				url: '<?php echo site_url('/site_info/add') ?>',
				dataType: 'json',
				type: 'GET',
				data: { cmd: 'GET_CME_PARTNER', key: req.term },
				beforeSend: function() {
					//$('input[name="merchantBranchName"]').after('<span id="loading" class="price"><img src="<?php echo base_url('/assets/images/loading.gif') ?>" /></span>');
				},
				success: function(json) {
					resp(json.data);
				},
				complete: function() {
					//$('#loading').remove();
				}
			});
		},
		open: function(e, ui) {
            var  acData = $(this).data('autocomplete');
			var termTemplate = '<strong>%s</strong>';
            
			acData.menu.element.find('a').each(function() {
                var me = $(this);
                var regex = new RegExp(acData.term, "gi");
                me.html( me.text().replace(regex, function (matched) {
                    return termTemplate.replace('%s', matched);
                }) );
            });
        },
		select: function(event, ui) {
			document.getElementsByName('cmePartner')[0].value = ui.item.id;
		},
		change: function(event, ui) {
			if (ui.item.id == '') {
				document.getElementById('cmePartnerName').value = '';
			}
		}
	});
	
});


var clearAutocomplete = function() {
	var input = document.getElementsByTagName('input');
	for (var i = 0; i < input.length; i++) {
		if (input[i].type == 'text') {
			input[i].setAttribute('autocomplete', 'off');
		}
	}
};
clearAutocomplete();

//--></script>

<script src="<?php echo base_url('/assets/js/number_format.js') ?>"></script>
<script><!--
var currency = document.getElementsByClassName('currency');
var number = document.getElementsByClassName('number');
var latLngNumber = document.getElementsByClassName('latlng-number');

var currencyOnSubmit = function() {
	for (var i = 0; i < currency.length; i++) {
		var prec = currency[i].value.split('.');
		if (prec[1] == '00') {
			currency[i].value = number_format(currency[i].value, '', '', '');
		} else {
			currency[i].value = number_format(currency[i].value, 2, '.', '');
		}
	}
};

var numberOnSubmit = function() {
	for (var i = 0; i < number.length; i++) {
		var prec = number[i].value.split('.');
		if (prec[1] == '00') {
			number[i].value = number_format(number[i].value, '', '', '');
		} else {
			number[i].value = number_format(number[i].value, 2, '.', '');
		}
	}
};

for (var i = 0; i < currency.length; i++) {
	// load default
	currency[i].value = number_format(currency[i].value, 2);
	
	// onfocus
	currency[i].onfocus = function() {
		var prec = this.value.split('.');
		if (prec[1] == '00') {
			this.value = number_format(this.value, '', '', '');
		} else {
			this.value = number_format(this.value, 2, '.', '');
		}
	};
	
	// onblur
	currency[i].onblur = function(e) {
		this.value = number_format(this.value, 2);
	};
	
	// onkeyup
	currency[i].onkeyup = function(e) {
		if (!isNumeric(this.value)) {
			alert('Please enter only numbers or decimal points.'); 
			setTimeout(function() { e.target.focus() });
			return false; 
		}
	};
}

for (var i = 0; i < number.length; i++) {
	// load default
	number[i].value = number_format(number[i].value, 2, '.', '');
	
	// onfocus
	number[i].onfocus = function() {
		var prec = this.value.split('.');
		if (prec[1] == '00') {
			this.value = number_format(this.value, '', '', '');
		} else {
			this.value = number_format(this.value, 2, '.', '');
		}
	};
	
	// onblur
	number[i].onblur = function() {
		this.value = number_format(this.value, 2, '.', '');
	};
	
	// onkeyup
	number[i].onkeyup = function(e) {
		if (!isNumeric(this.value)) {
			alert('Please enter only numbers or decimal points.'); 
			setTimeout(function() { e.target.focus() });
			return false; 
		}
	};
}

for (var i = 0; i < latLngNumber.length; i++) {
	latLngNumber[i].onkeyup = function(e) {
		if (!isNumeric(this.value)) {
			alert('Please enter only numbers or decimal points.'); 
			setTimeout(function() { e.target.focus() });
			return false; 
		}
	};
	
	latLngNumber[i].onblur = function(e) {
		if (this.value.indexOf('.') != -1) {
			var prec = this.value.split('.');
			if (prec[1].length >= 6) {
				this.value = number_format(this.value, 6, '.', '');
			} else {
				this.value = number_format(this.value, prec[1].length, '.', '');
			}
		}
	};
}

var isNumeric = function(sText) {
	var validChars = "0123456789.-";
	var isNumber = true;
	var character;
 
	for (var i = 0; i < sText.length && isNumber == true; i++) { 
		character = sText.charAt(i);
		if (validChars.indexOf(character) == -1) {
			isNumber = false;
		}
	}
	
	return isNumber;
};

var clearField = function(field) {
	document.getElementById(field).value = '';
};

var uppercaseElement = document.getElementsByClassName('uppercase');
for (var i = 0; i < uppercaseElement.length; i++) {
	uppercaseElement[i].onkeyup = function() {
		this.value = this.value.toUpperCase();
	};
};

var siteOverlay = {
	
	/**
	 * for window overlay
	 * Author: ttg <tatangalmubarak@gmail.com>
	 * Desc: hehehe...
	 */
	
	message: null,	// text message
	left: null,		// pixel
	top: null,		// pixel
	create: function() {
		var overlay = document.createElement('div');
		
		overlay.setAttribute('id', 'site-overlay');
		overlay.style.position = 'fixed';
		overlay.style.top = '0px';
		overlay.style.bottom = '0px';
		overlay.style.zIndex = 99999;
		overlay.style.width = '100%';
		overlay.style.height = '100%';
		overlay.style.background = 'rgba(0, 0, 0, 0.6)';
		document.body.appendChild(overlay);
		
		var h1 = document.createElement('h1');
		if (this.message == null) {
			this.message = document.createTextNode('Loading, please wait...');
		}
		
		h1.setAttribute('id', 'overlay-message');
		h1.style.width = '300px';
		h1.appendChild(this.message);
		overlay.appendChild(h1);
		
		var windowWidth = document.body.clientWidth;
		var windowHeight = document.body.clientHeight;
		var h1Width = document.getElementById('overlay-message').offsetWidth;
		var h1Height = document.getElementById('overlay-message').offsetHeight;
		if (this.left == null) {
			this.left = (windowWidth - h1Width) / 2 + 'px';
		}
		if (this.top == null) {
			this.top = (windowHeight - h1Height) / 2 + 'px';
		}
		
		var overlayMessage = document.getElementById('overlay-message');
		overlayMessage.style.position = 'absolute';
		overlayMessage.style.zIndex = 999999;
		overlayMessage.style.top = this.top;
		overlayMessage.style.left = this.left;
		overlayMessage.style.width = '300px';
		overlayMessage.style.border = '2px solid #468847';
		overlayMessage.style.background = '#FCF8E3';
		overlayMessage.style.textAlign = 'center';
		overlayMessage.style.padding = '10px';
		overlayMessage.style.color = '#C09853';
		overlayMessage.style.fontSize = '16px';
	},
	remove: function() {
		var siteOverlay = document.getElementById('site-overlay');
		
		if (siteOverlay != null) {
			siteOverlay.parentNode.removeChild(siteOverlay);
		}
	}
};
//--></script>